<?php

class WcmController extends Controller{

    protected $regions=array();

	/**
	 * @param WidgetInstance $widget
	 * @param string $region
	 */
    public function addWidgetToRegion(WidgetInstance $widget,String $region){
        $this->regions[$region][] = $widget;
    }
	
	
	/**
	 * @param $region string
	 * @return array
	 */
    public function getRegionWidgets($region){
    	$region = Region::model()->with('widgets')->find('t.name=:name', array(':name'=>$region));
		return $region->widgets;
    }
	
	/**
	 * @param $widget WidgetInstance
	 */
	public function renderWidget($instance){
		$this->widget($instance->getClass(), array('instance'=>$instance));
	}
	
    public function actionIndex(){
		
		//$widgetName = "WCMMenuWidget";
		//$widget = new $widgetName("bla");
		//$className = Yii::import("application.wcmwidgets.WCMMenuWidget");
		//$widget = new $className("bla");
		//$this->addWidgetToRegion($widget, 'MainMenu');
        $this->render('index');
    }

}
